package cn.com.eado.crm.m.db

import androidx.lifecycle.LiveData
import androidx.room.*
import cn.com.eado.crm.m.db.AppIcon


@Dao
interface AppIconDao {
    @Insert//(onConflict = OnConflictStrategy.REPLACE)
    fun insert(appIcon: AppIcon)

    @Insert//(onConflict = OnConflictStrategy.REPLACE)
    fun insertAll(appIcons: List<AppIcon>)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun replaceAll(appIcons: List<AppIcon>)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun replace(appIcon: AppIcon)

    @Delete
    fun delete(appIcon: AppIcon)

    @Delete
    fun delete(appIcons: List<AppIcon>)

    @Update
    fun update(appIcon: AppIcon)

    @Query("select * from app_icon")  //查询所有
    fun queryAll(): LiveData<List<AppIcon>>

    @Query("select * from app_icon where userId = :userId")  //查询所有
    fun queryAll(userId: Int): List<AppIcon>?  //即使没有数据返回的也不少null，而是[]

    @Query("select * from app_icon where show = :show and userId = :userId")  //查询所有
    fun queryShow(show: Boolean, userId: Int): List<AppIcon>?

    @Query("select * from app_icon where show = :show and userId = :userId and name = :name")
    fun queryShowWithName(show: Boolean, userId: Int, name: String): AppIcon?

}